#pragma once
#include "boost/asio.hpp"

#include <map>
#include <string>
#include <memory>
#include <mutex>


class CSession;

class CServer
{

public:
    CServer(boost::asio::io_context& io_context,short port);
    ~CServer();
    void ClearSession(const std::string& session_id);
    void Start();
    void HandleAccept(std::shared_ptr<CSession> session,
                        const boost::system::error_code& ec);

private:
    boost::asio::io_context& _io_context;
    boost::asio::ip::tcp::acceptor _acceptor;
    std::map<std::string,std::shared_ptr<CSession>> _sessions;
    std::mutex _sessions_mutex;
    
    short _port;

};

